package com.mars.servlet;

import com.mars.util.constant;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String user_session = (String)req.getSession().getAttribute(constant.USER_SESSION);
        if(user_session!=null){
            req.getSession().removeAttribute(constant.USER_SESSION);
            resp.sendRedirect("/login.jsp");
        }



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
